package org.skyeye.modeling.commands;

import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.draw2d.geometry.Point;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.gef.commands.Command;

import org.skyeye.modeling.model.MNode;
import org.skyeye.modeling.model.MSOC;
import org.skyeye.modeling.model.MRoot;
public class MoveAndResizeNodeCommand extends Command {
	private MNode node;

	private Rectangle oldRect;  
	private Rectangle newRect;  

	public MoveAndResizeNodeCommand(MNode node, Rectangle newRect) {  
		this.node = node;  
		this.newRect = newRect; 
		
		}  
		@Override  
		public void execute() {  
		oldRect = new Rectangle(node.getLocation().x, node.getLocation().y, node.getSize().width, node.getSize().height);  
		node.setLocation(new Point(newRect.x,newRect.y));
		node.setSize(new Dimension(newRect.width,newRect.height)); 
		
		}  
		@Override  
		public void undo() {  
			node.setLocation(new Point(oldRect.x,oldRect.y));
			node.setSize(new Dimension(oldRect.width,oldRect.height));  
		}  
}